﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using gecommon;
using gerecord.Command;

namespace gerecord
{
    public class DownStream<TKey, TEntity> : IDownStream<TKey, TEntity>
    {
        private IWriter<ICommand> _writer;

        private IReader<ICommand> _reader;

        public DownStream(IWriter<ICommand> writer, IReader<ICommand> reader)
        {
            _writer = writer;
            _reader = reader;
        }

        public async Task UpdateAsync(UpdateCommand<TKey, TEntity> cmd)
        {
            await _writer.WriteAsync(cmd);
        }

        public async Task<ICommand> WaitAsync()
        {
            return await _reader.ReadAsync();
        }
    }
}
